<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>正则</title>
</head>
<body>
<input type="text" placeholder="input a number" id="i"/>
<script>
    var oInput=document.querySelector("#i");
    oInput.onchange=function(){
        var v=oInput.value;
        var re=/^\d+$/g;
        if(re.test(v)){
            alert("ok")
        }else{
            alert("false")
        }
    }


</script>
</body>
</html>